package pk232guru;

//import com.sun.glass.events.MouseEvent;
import gnu.io.*;
//import java.awt.Dialog;
import java.io.*;
//import java.util.*;
import org.ini4j.*;
//import java.lang.*;
//import javafx.scene.input.MouseButton;
//import javax.swing.SwingUtilities;
//import javax.swing.SwingWorker;
//import javax.swing.*;
//import javax.swing.event.*;
//import javax.swing.text.*;
import java.util.concurrent.TimeUnit;
//import java.net.*;

public class pk232guru extends javax.swing.JFrame {

    public pk232guru() {
        initComponents();
    }
    static String giniCommport;
    static String giniBaudrate;
    static String giniDatabits;
    static String giniStopbits;
    static String giniParity;
    static String giniDelay;
    static String giniMycall;
    static String giniMyname;
    static String giniFilename = "pk232.ini";
    static String giniServerPort;
    static boolean cmdReceived = false;
    static boolean convMode = false;
    static boolean noCommport = true;
    static boolean hostMode = false;
    static boolean hostmodeDesired = false;
    static boolean getCWspeed = false;
    static boolean getOpMode = false;
    //static boolean dispOPmode = false;
    public static final char LF = '\n';
    public static final char CR = '\r';
    static String serialOutput = new String();
    static int cwSpeed = 20;
    static StringBuffer serialData2pk = new StringBuffer();
    static boolean cwAuto = false;
    static boolean cwDataSent = false;
    //static char whatCWcharSent = 0;
    static boolean cwXmit = false;
    static boolean dataACK = false;
    static boolean cwACKwait = false;
    static boolean dataFinished = false;

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jFileChooseINI = new javax.swing.JFileChooser();
        jPopupMenuOutput = new javax.swing.JPopupMenu();
        jMenuItemOutputClear = new javax.swing.JMenuItem();
        jMenuItemOutputCopy = new javax.swing.JMenuItem();
        jMenuItemOutputSelAll = new javax.swing.JMenuItem();
        jPopupMenuInput = new javax.swing.JPopupMenu();
        jMenuItemInputClear = new javax.swing.JMenuItem();
        jMenuItemInputCopy = new javax.swing.JMenuItem();
        jMenuItemInputSelAll = new javax.swing.JMenuItem();
        jDialogAbout = new javax.swing.JDialog();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jButtonAboutOk = new javax.swing.JButton();
        buttonGroupMode = new javax.swing.ButtonGroup();
        buttonGroupRxTx = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jTabbedPaneMain = new javax.swing.JTabbedPane();
        jPanelMain = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextAreaSerialIn = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextAreaSerialOut = new javax.swing.JTextArea();
        jLabelMode = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabelMorseSpeed = new javax.swing.JLabel();
        jLabelCWspeed = new javax.swing.JLabel();
        jRadioButtonRx = new javax.swing.JRadioButton();
        jRadioButtonTx = new javax.swing.JRadioButton();
        jToggleButtonMOauto = new javax.swing.JToggleButton();
        jSliderCWspeed = new javax.swing.JSlider();
        jTextFieldCode2send = new javax.swing.JTextField();
        jButtonSendCode = new javax.swing.JButton();
        jPanelPersonal = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jTextFieldMyCall = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jTextFieldMyName = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jTextFieldMyGrid = new javax.swing.JTextField();
        jPanelSettings = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jComboBoxPort = new javax.swing.JComboBox();
        jButtonReadINI = new javax.swing.JButton();
        jButtonWriteINI = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jComboBoxDatabits = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jComboBoxParity = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jComboBoxStopbits = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jComboBoxBaudrate = new javax.swing.JComboBox();
        jButtonConnect = new javax.swing.JButton();
        jLabelConStatus = new javax.swing.JLabel();
        jRadioButtonModeMO = new javax.swing.JRadioButton();
        jRadioButtonModePA = new javax.swing.JRadioButton();
        jRadioButtonModePT = new javax.swing.JRadioButton();
        jRadioButtonModeBA = new javax.swing.JRadioButton();
        jRadioButtonModeAM = new javax.swing.JRadioButton();
        jRadioButtonModeAS = new javax.swing.JRadioButton();
        jLabel11 = new javax.swing.JLabel();
        jComboBoxDelay = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jButtonOuttaHost = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jToggleButtonServerOn = new javax.swing.JToggleButton();
        jTextFieldServerPort = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenuFile = new javax.swing.JMenu();
        jMenuExit = new javax.swing.JMenuItem();
        jMenuHelp = new javax.swing.JMenu();
        jMenuHelpAbout = new javax.swing.JMenuItem();

        jMenuItemOutputClear.setText("Clear");
        jMenuItemOutputClear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemOutputClearActionPerformed(evt);
            }
        });
        jPopupMenuOutput.add(jMenuItemOutputClear);

        jMenuItemOutputCopy.setText("Copy");
        jMenuItemOutputCopy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemOutputCopyActionPerformed(evt);
            }
        });
        jPopupMenuOutput.add(jMenuItemOutputCopy);

        jMenuItemOutputSelAll.setText("Select All");
        jMenuItemOutputSelAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemOutputSelAllActionPerformed(evt);
            }
        });
        jPopupMenuOutput.add(jMenuItemOutputSelAll);

        jMenuItemInputClear.setText("Clear");
        jMenuItemInputClear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemInputClearActionPerformed(evt);
            }
        });
        jPopupMenuInput.add(jMenuItemInputClear);

        jMenuItemInputCopy.setText("Copy");
        jMenuItemInputCopy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemInputCopyActionPerformed(evt);
            }
        });
        jPopupMenuInput.add(jMenuItemInputCopy);

        jMenuItemInputSelAll.setText("Select All");
        jMenuItemInputSelAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemInputSelAllActionPerformed(evt);
            }
        });
        jPopupMenuInput.add(jMenuItemInputSelAll);

        jDialogAbout.setTitle("About pk232guru");
        jDialogAbout.setBounds(new java.awt.Rectangle(0, 0, 400, 200));
        jDialogAbout.setModal(true);

        jLabel7.setText("Programming: David S. Berkompas - AI6K");

        jLabel8.setText("Design: David S. Berkompas - AI6K");

        jButtonAboutOk.setText("Ok");
        jButtonAboutOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAboutOkActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jDialogAboutLayout = new javax.swing.GroupLayout(jDialogAbout.getContentPane());
        jDialogAbout.getContentPane().setLayout(jDialogAboutLayout);
        jDialogAboutLayout.setHorizontalGroup(
            jDialogAboutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialogAboutLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jDialogAboutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jDialogAboutLayout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 106, Short.MAX_VALUE)
                        .addComponent(jButtonAboutOk))
                    .addGroup(jDialogAboutLayout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jDialogAboutLayout.setVerticalGroup(
            jDialogAboutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialogAboutLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 90, Short.MAX_VALUE)
                .addComponent(jButtonAboutOk)
                .addContainerGap())
        );

        jDialogAbout.getAccessibleContext().setAccessibleDescription("");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                formComponentShown(evt);
            }
        });

        jTextAreaSerialIn.setColumns(20);
        jTextAreaSerialIn.setEditable(false);
        jTextAreaSerialIn.setLineWrap(true);
        jTextAreaSerialIn.setRows(5);
        jTextAreaSerialIn.setComponentPopupMenu(jPopupMenuInput);
        jScrollPane1.setViewportView(jTextAreaSerialIn);

        jTextAreaSerialOut.setColumns(20);
        jTextAreaSerialOut.setRows(3);
        jTextAreaSerialOut.setComponentPopupMenu(jPopupMenuOutput);
        jTextAreaSerialOut.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextAreaSerialOutKeyTyped(evt);
            }
        });
        jScrollPane2.setViewportView(jTextAreaSerialOut);

        jLabelMode.setText("Disconnected");

        jLabel9.setText("Status:");

        jLabel10.setText("CW Speed:");

        jLabelCWspeed.setText("20");

        buttonGroupRxTx.add(jRadioButtonRx);
        jRadioButtonRx.setForeground(new java.awt.Color(0, 204, 0));
        jRadioButtonRx.setText("Rx");
        jRadioButtonRx.setEnabled(false);
        jRadioButtonRx.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonRxActionPerformed(evt);
            }
        });

        buttonGroupRxTx.add(jRadioButtonTx);
        jRadioButtonTx.setForeground(new java.awt.Color(204, 0, 102));
        jRadioButtonTx.setText("Tx");
        jRadioButtonTx.setEnabled(false);
        jRadioButtonTx.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonTxActionPerformed(evt);
            }
        });

        jToggleButtonMOauto.setText("CW Auto");
        jToggleButtonMOauto.setEnabled(false);
        jToggleButtonMOauto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonMOautoActionPerformed(evt);
            }
        });

        jSliderCWspeed.setMajorTickSpacing(10);
        jSliderCWspeed.setMaximum(99);
        jSliderCWspeed.setMinimum(5);
        jSliderCWspeed.setMinorTickSpacing(1);
        jSliderCWspeed.setPaintLabels(true);
        jSliderCWspeed.setPaintTicks(true);
        jSliderCWspeed.setValue(20);

        jButtonSendCode.setText("Send Code");
        jButtonSendCode.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSendCodeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelMainLayout = new javax.swing.GroupLayout(jPanelMain);
        jPanelMain.setLayout(jPanelMainLayout);
        jPanelMainLayout.setHorizontalGroup(
            jPanelMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 659, Short.MAX_VALUE)
            .addComponent(jScrollPane1)
            .addGroup(jPanelMainLayout.createSequentialGroup()
                .addComponent(jToggleButtonMOauto)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jRadioButtonRx)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jRadioButtonTx)
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelMainLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jButtonSendCode, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jTextFieldCode2send))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanelMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelMainLayout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelCWspeed, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jSliderCWspeed, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelMorseSpeed)
                .addGap(89, 89, 89)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelMode, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanelMainLayout.setVerticalGroup(
            jPanelMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelMainLayout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(jPanelMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelMainLayout.createSequentialGroup()
                        .addGroup(jPanelMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelMainLayout.createSequentialGroup()
                                .addGap(12, 12, 12)
                                .addGroup(jPanelMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabelMode, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel9)
                                    .addComponent(jLabelMorseSpeed)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelMainLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanelMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel10)
                                    .addComponent(jLabelCWspeed))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSliderCWspeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelMainLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldCode2send, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonSendCode)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
                .addGroup(jPanelMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jToggleButtonMOauto)
                    .addComponent(jRadioButtonRx)
                    .addComponent(jRadioButtonTx))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jTabbedPaneMain.addTab("Main", jPanelMain);

        jLabel12.setText("Calllsign:");

        jTextFieldMyCall.setText("NONE");
        jTextFieldMyCall.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldMyCallActionPerformed(evt);
            }
        });
        jTextFieldMyCall.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldMyCallFocusLost(evt);
            }
        });

        jLabel13.setText("Name:");

        jTextFieldMyName.setText("None");
        jTextFieldMyName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldMyNameActionPerformed(evt);
            }
        });

        jLabel17.setText("Grid:");

        jTextFieldMyGrid.setText("AB34ef");

        javax.swing.GroupLayout jPanelPersonalLayout = new javax.swing.GroupLayout(jPanelPersonal);
        jPanelPersonal.setLayout(jPanelPersonalLayout);
        jPanelPersonalLayout.setHorizontalGroup(
            jPanelPersonalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelPersonalLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelPersonalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelPersonalLayout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldMyCall, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelPersonalLayout.createSequentialGroup()
                        .addGroup(jPanelPersonalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel13)
                            .addComponent(jLabel17))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelPersonalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldMyGrid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldMyName, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(468, Short.MAX_VALUE))
        );

        jPanelPersonalLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel12, jLabel13});

        jPanelPersonalLayout.setVerticalGroup(
            jPanelPersonalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelPersonalLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelPersonalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jTextFieldMyCall, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelPersonalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(jTextFieldMyName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelPersonalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(jTextFieldMyGrid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(408, Short.MAX_VALUE))
        );

        jTabbedPaneMain.addTab("Personal", jPanelPersonal);

        jLabel1.setText("Comm Port:");

        jComboBoxPort.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select One", "Refresh" }));
        jComboBoxPort.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxPortActionPerformed(evt);
            }
        });
        jComboBoxPort.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jComboBoxPortFocusLost(evt);
            }
        });

        jButtonReadINI.setText("Read");
        jButtonReadINI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonReadINIActionPerformed(evt);
            }
        });

        jButtonWriteINI.setText("Write");
        jButtonWriteINI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonWriteINIActionPerformed(evt);
            }
        });

        jLabel2.setText("Configuration:");

        jLabel3.setText("Data bits:");

        jComboBoxDatabits.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "8", "7", "6", "5" }));
        jComboBoxDatabits.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxDatabitsActionPerformed(evt);
            }
        });
        jComboBoxDatabits.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jComboBoxDatabitsFocusLost(evt);
            }
        });

        jLabel4.setText("Parity:");

        jComboBoxParity.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "EVEN", "MARK", "NONE", "ODD", "SPACE" }));
        jComboBoxParity.setSelectedIndex(2);
        jComboBoxParity.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxParityActionPerformed(evt);
            }
        });
        jComboBoxParity.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jComboBoxParityFocusLost(evt);
            }
        });

        jLabel5.setText("Stop bits:");

        jComboBoxStopbits.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "1.5", "2" }));
        jComboBoxStopbits.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxStopbitsActionPerformed(evt);
            }
        });
        jComboBoxStopbits.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jComboBoxStopbitsFocusLost(evt);
            }
        });

        jLabel6.setText("Baud Rate:");

        jComboBoxBaudrate.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "19200", "9600", "2400", "1200", "300" }));
        jComboBoxBaudrate.setSelectedIndex(1);
        jComboBoxBaudrate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxBaudrateActionPerformed(evt);
            }
        });
        jComboBoxBaudrate.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jComboBoxBaudrateFocusLost(evt);
            }
        });

        jButtonConnect.setText("Connect");
        jButtonConnect.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonConnectActionPerformed(evt);
            }
        });

        jLabelConStatus.setText("Disconnected");

        buttonGroupMode.add(jRadioButtonModeMO);
        jRadioButtonModeMO.setText("CW");
        jRadioButtonModeMO.setEnabled(false);
        jRadioButtonModeMO.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonModeMOActionPerformed(evt);
            }
        });

        buttonGroupMode.add(jRadioButtonModePA);
        jRadioButtonModePA.setText("Packet");
        jRadioButtonModePA.setEnabled(false);
        jRadioButtonModePA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonModePAActionPerformed(evt);
            }
        });

        buttonGroupMode.add(jRadioButtonModePT);
        jRadioButtonModePT.setText("Pactor");
        jRadioButtonModePT.setEnabled(false);

        buttonGroupMode.add(jRadioButtonModeBA);
        jRadioButtonModeBA.setText("Baudot RTTY");
        jRadioButtonModeBA.setEnabled(false);

        buttonGroupMode.add(jRadioButtonModeAM);
        jRadioButtonModeAM.setText("Amtor");
        jRadioButtonModeAM.setEnabled(false);

        buttonGroupMode.add(jRadioButtonModeAS);
        jRadioButtonModeAS.setText("Ascii RTTY");
        jRadioButtonModeAS.setEnabled(false);
        jRadioButtonModeAS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonModeASActionPerformed(evt);
            }
        });

        jLabel11.setText("Wait Delay");

        jComboBoxDelay.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5" }));
        jComboBoxDelay.setSelectedIndex(2);
        jComboBoxDelay.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxDelayActionPerformed(evt);
            }
        });
        jComboBoxDelay.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jComboBoxDelayFocusLost(evt);
            }
        });

        jLabel14.setText("Mode:");

        jLabel15.setText("Status:");

        jButtonOuttaHost.setText("Get me outta host mode.");
        jButtonOuttaHost.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonOuttaHostActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelSettingsLayout = new javax.swing.GroupLayout(jPanelSettings);
        jPanelSettings.setLayout(jPanelSettingsLayout);
        jPanelSettingsLayout.setHorizontalGroup(
            jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelSettingsLayout.createSequentialGroup()
                .addGroup(jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelSettingsLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanelSettingsLayout.createSequentialGroup()
                                .addGroup(jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jPanelSettingsLayout.createSequentialGroup()
                                        .addGroup(jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanelSettingsLayout.createSequentialGroup()
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 4, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel14))
                                            .addComponent(jRadioButtonModeMO))
                                        .addGap(87, 87, 87)
                                        .addComponent(jButtonConnect))
                                    .addGroup(jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jButtonReadINI)
                                        .addComponent(jLabel2)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel15)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabelConStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButtonOuttaHost))
                            .addGroup(jPanelSettingsLayout.createSequentialGroup()
                                .addGroup(jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanelSettingsLayout.createSequentialGroup()
                                        .addComponent(jComboBoxPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jComboBoxBaudrate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jComboBoxDatabits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jComboBoxParity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jRadioButtonModeBA)
                                    .addComponent(jRadioButtonModeAM)
                                    .addComponent(jRadioButtonModeAS)
                                    .addGroup(jPanelSettingsLayout.createSequentialGroup()
                                        .addGroup(jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jRadioButtonModePT)
                                            .addComponent(jRadioButtonModePA))
                                        .addGap(170, 170, 170)
                                        .addComponent(jButtonWriteINI)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboBoxStopbits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jComboBoxDelay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanelSettingsLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel1)
                        .addGap(12, 12, 12)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel5)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel11)))
                .addContainerGap(75, Short.MAX_VALUE))
        );

        jPanelSettingsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jComboBoxBaudrate, jComboBoxDatabits, jComboBoxParity, jComboBoxPort, jComboBoxStopbits, jLabel1, jLabel3, jLabel4, jLabel5, jLabel6});

        jPanelSettingsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jRadioButtonModeAM, jRadioButtonModeAS, jRadioButtonModeBA, jRadioButtonModeMO, jRadioButtonModePA, jRadioButtonModePT});

        jPanelSettingsLayout.setVerticalGroup(
            jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelSettingsLayout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addGroup(jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel3)
                        .addComponent(jLabel4)
                        .addComponent(jLabel5)
                        .addComponent(jLabel6)
                        .addComponent(jLabel11)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jComboBoxPort, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jComboBoxDatabits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jComboBoxParity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jComboBoxStopbits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jComboBoxBaudrate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jComboBoxDelay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelSettingsLayout.createSequentialGroup()
                        .addGroup(jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButtonConnect)
                            .addComponent(jLabel15)
                            .addComponent(jLabelConStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonOuttaHost))
                        .addGap(18, 18, 18)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButtonReadINI)
                            .addComponent(jButtonWriteINI)))
                    .addGroup(jPanelSettingsLayout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRadioButtonModeMO)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRadioButtonModePA)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRadioButtonModePT)
                        .addGap(5, 5, 5)
                        .addComponent(jRadioButtonModeBA)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRadioButtonModeAM)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRadioButtonModeAS)))
                .addContainerGap(256, Short.MAX_VALUE))
        );

        jPanelSettingsLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jComboBoxBaudrate, jComboBoxDatabits, jComboBoxParity, jComboBoxPort, jComboBoxStopbits, jLabel3, jLabel4, jLabel5, jLabel6});

        jTabbedPaneMain.addTab("Settings", jPanelSettings);

        jToggleButtonServerOn.setText("Server Off");
        jToggleButtonServerOn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonServerOnActionPerformed(evt);
            }
        });

        jTextFieldServerPort.setText("4442");
        jTextFieldServerPort.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldServerPortActionPerformed(evt);
            }
        });
        jTextFieldServerPort.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldServerPortFocusLost(evt);
            }
        });

        jLabel16.setText("Server Port:");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jToggleButtonServerOn)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldServerPort, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(540, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jToggleButtonServerOn)
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(jTextFieldServerPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(429, Short.MAX_VALUE))
        );

        jTabbedPaneMain.addTab("Server", jPanel2);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPaneMain, javax.swing.GroupLayout.Alignment.TRAILING)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jTabbedPaneMain, javax.swing.GroupLayout.PREFERRED_SIZE, 529, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 11, Short.MAX_VALUE))
        );

        jMenuFile.setText("File");

        jMenuExit.setText("Exit");
        jMenuExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuExitActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuExit);

        jMenuBar1.add(jMenuFile);

        jMenuHelp.setText("Help");

        jMenuHelpAbout.setText("About");
        jMenuHelpAbout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuHelpAboutActionPerformed(evt);
            }
        });
        jMenuHelp.add(jMenuHelpAbout);

        jMenuBar1.add(jMenuHelp);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuExitActionPerformed
        System.exit(0);

    }//GEN-LAST:event_jMenuExitActionPerformed

    private void jMenuHelpAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuHelpAboutActionPerformed
        jLabel7.setText("Programming: David S. Berkompas - AI6K");
        jLabel8.setText("Design: David S. Berkompas - AI6K");
        jDialogAbout.setLocation(this.getLocationOnScreen().x + 35, this.getLocationOnScreen().y + 35);
        jDialogAbout.setVisible(true);
    }//GEN-LAST:event_jMenuHelpAboutActionPerformed

    private void jComboBoxPortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxPortActionPerformed
        if (jComboBoxPort.isFocusOwner()) {
            if (jComboBoxPort.getSelectedIndex() == 1) {
                // Refresh this combo box
                jComboBoxPort.removeAllItems();
                jComboBoxPort.addItem("Select One");
                jComboBoxPort.addItem("Refresh");
                jComboBoxPort.addItem(giniCommport);
                listPorts();
                jComboBoxPort.setSelectedItem(giniCommport);
            } else if (jComboBoxPort.getSelectedIndex() != 0) {
                giniCommport = jComboBoxPort.getSelectedItem().toString();
            }
        }
    }//GEN-LAST:event_jComboBoxPortActionPerformed

    private void jButtonReadINIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonReadINIActionPerformed
        jFileChooseINI.setCurrentDirectory(new java.io.File("."));
        jFileChooseINI.setAcceptAllFileFilterUsed(false);
        File confFile = new File("pk232.ini");
        jFileChooseINI.setSelectedFile(confFile);
        int rVal = jFileChooseINI.showOpenDialog(null);
        if (rVal == 0) {
            giniFilename = jFileChooseINI.getSelectedFile().toString();
            try {
                getIniContents(giniFilename);
            } catch (java.io.IOException exp) {
                System.out.println("How are you going to get here if the file doesn't exist.");
            }
        }
    }//GEN-LAST:event_jButtonReadINIActionPerformed

    private void jButtonWriteINIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonWriteINIActionPerformed
        jFileChooseINI.setCurrentDirectory(new java.io.File("."));
        jFileChooseINI.setAcceptAllFileFilterUsed(false);
        File confFile = new File("pk232.ini");
        jFileChooseINI.setSelectedFile(confFile);
        int rVal = jFileChooseINI.showSaveDialog(null);
        if (rVal == 0) {
            giniFilename = jFileChooseINI.getSelectedFile().toString();
            try {
                setIniContents(giniFilename);
            } catch (java.io.IOException exp) {
                File f;
                f = new File(giniFilename);
                if (!f.exists()) {
                    try {
                        f.createNewFile();
                        setIniContents(giniFilename);
                    } catch (java.io.IOException exp2) {
                        System.out.println("For some reason, the configuration file couldn't be written.\n");
                    }
                }
            }
        }
    }//GEN-LAST:event_jButtonWriteINIActionPerformed

    private void jComboBoxDatabitsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxDatabitsActionPerformed
        if (jComboBoxDatabits.isFocusOwner()) {
            giniDatabits = jComboBoxDatabits.getSelectedItem().toString().toUpperCase();
        }
    }//GEN-LAST:event_jComboBoxDatabitsActionPerformed

    private void jComboBoxParityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxParityActionPerformed
        if (jComboBoxParity.isFocusOwner()) {
            giniParity = jComboBoxParity.getSelectedItem().toString().toUpperCase();
        }
    }//GEN-LAST:event_jComboBoxParityActionPerformed

    private void jComboBoxStopbitsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxStopbitsActionPerformed
        if (jComboBoxStopbits.isFocusOwner()) {
            giniStopbits = jComboBoxStopbits.getSelectedItem().toString().toUpperCase();
        }
    }//GEN-LAST:event_jComboBoxStopbitsActionPerformed

    private void jComboBoxBaudrateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxBaudrateActionPerformed
        if (jComboBoxBaudrate.isFocusOwner()) {
            giniBaudrate = jComboBoxBaudrate.getSelectedItem().toString().toUpperCase();
        }
    }//GEN-LAST:event_jComboBoxBaudrateActionPerformed

    private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
        // Using this to run things once the main window is instantiated
        try {
            getIniContents(giniFilename);
        } catch (java.io.IOException exp) {
            // The ini file wasn't found, create if possible
            File f;
            f = new File(giniFilename);
            if (!f.exists()) {
                try {
                    f.createNewFile();
                    giniCommport = "COM3";
                    giniBaudrate = "9600";
                    giniDatabits = "8";
                    giniStopbits = "1";
                    giniParity = "NONE";
                    giniDelay = "2";
                    giniMycall = "NONE";
                    giniServerPort = "4442";
                    giniMyname = "Juan";
                    setIniContents(giniFilename);
                } catch (java.io.IOException exp2) {
                    System.out.println("For some reason, the ini file couldn't be written.\n");
                    jLabel7.setText("Unable to write config file.");
                    jLabel8.setText(null);
                    jDialogAbout.setLocation(this.getLocationOnScreen().x + 35, this.getLocationOnScreen().y + 35);
                    jDialogAbout.setVisible(true);
                }
            }
        }
        jComboBoxPort.removeAllItems();
        jComboBoxPort.addItem("Select One");
        jComboBoxPort.addItem("Refresh");
        jComboBoxPort.addItem(giniCommport);
        listPorts();
        jComboBoxPort.setSelectedItem(giniCommport);
    }//GEN-LAST:event_formComponentShown

    private void jButtonConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConnectActionPerformed
        if (hostMode == false) {
            // Connect clicked
            cmdReceived = false;
            convMode = false;
            hostmodeDesired = true;
            try {
                (new pk232comms()).connect(giniCommport, giniStopbits, giniParity, giniDatabits, giniBaudrate);
            } catch (Exception noComms01) {
                noComms01.printStackTrace();
            }
            for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                // Pause for a bit to let the connect happen.
            }
            try {
                pk232comms.outStream.write(new byte[]{1});
            } catch (Exception noComms02) {
                noComms02.printStackTrace();
            }
            for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(500); stop > System.nanoTime();) {
                // Pause for a bit to let the CTRL signal get through
            }
            // Test to see if we're in host mode.
            try {
                pk232comms.outStream.write(new byte[]{1, 79, 71, 71, 23});
            } catch (Exception noComms03) {
                noComms03.printStackTrace();
            }
            //for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                // This pause is so that if Host mode worked, it can also get the mode and if cw, then get speed.
            //}
            long startTime;
            long endTime;
            long timeDiff;
            startTime = System.currentTimeMillis();
            while (hostMode == false) {
                endTime = System.currentTimeMillis();
                timeDiff = endTime - startTime;
                if (timeDiff > 1000) {
                    System.out.println("Took to long to get into HOST mode, try other modes.");
                    break;
                }
            }
            if (hostMode == false) {
                System.out.println("Trying ini settings.");
                try {
                    pk232comms.outStream.write(13);
                } catch (Exception noComms04) {
                    noComms04.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    if (cmdReceived == true) {
                        convMode = true;
                        noCommport = false;
                    }
                }
            }
            // Try sending 3 asterisks using settings from INI file
            if ((convMode == false) && (hostMode == false)) {
                System.out.println("Trying ini w/ asterisks");
                try {
                    pk232comms.outStream.write("***".getBytes("US-ASCII"));
                } catch (Exception noComms05) {
                    noComms05.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    if (cmdReceived == true) {
                        convMode = true;
                        noCommport = false;
                    }
                }
            }
            // Force 9600 baud, and try a carriage return
            if ((convMode == false) && (hostMode == false)) {
                System.out.println("Trying 9600baud CR/LF");
                try {
                    pk232comms.serialPort.close();
                } catch (Exception noComms06) {
                    noComms06.printStackTrace();
                }
                giniBaudrate = "9600";
                try {
                    (new pk232comms()).connect(giniCommport, giniStopbits, giniParity, giniDatabits, giniBaudrate);
                } catch (Exception noComms07) {
                    noComms07.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    // This pause is for when we changed comm parms
                }
                try {
                    pk232comms.outStream.write(13);
                } catch (Exception noComms08) {
                    noComms08.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    if (cmdReceived == true) {
                        convMode = true;
                        noCommport = false;
                        jComboBoxBaudrate.setSelectedItem(giniBaudrate);
                    }
                }
            }
            // Try 3 asterisks at 9600baud
            if ((convMode == false) && (hostMode == false)) {
                System.out.println("Trying 96000baud asterisk");
                pk232comms.serialPort.close();
                try {
                    (new pk232comms()).connect(giniCommport, giniStopbits, giniParity, giniDatabits, giniBaudrate);
                } catch (Exception noComms09) {
                    noComms09.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    // This pause is for when we changed comm parms
                }
                try {
                    pk232comms.outStream.write("***".getBytes("US-ASCII"));
                } catch (Exception noComms10) {
                    noComms10.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    if (cmdReceived == true) {
                        convMode = true;
                        noCommport = false;
                        jComboBoxBaudrate.setSelectedItem(giniBaudrate);
                    }
                }
            }
            // Force 1200 baud, and try a carriage return
            if ((convMode == false) && (hostMode == false)) {
                System.out.println("Trying 1200baud CR/LF");
                pk232comms.serialPort.close();
                giniBaudrate = "1200";
                try {
                    (new pk232comms()).connect(giniCommport, giniStopbits, giniParity, giniDatabits, giniBaudrate);
                } catch (Exception noComms11) {
                    noComms11.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    // This pause is for when we changed comm parms
                }
                try {
                    pk232comms.outStream.write(13);
                } catch (Exception noComms14) {
                    noComms14.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    if (cmdReceived == true) {
                        convMode = true;
                        noCommport = false;
                        jComboBoxBaudrate.setSelectedItem(giniBaudrate);
                    }
                }
            }
            // Try 3 asterisks at 1200baud
            if ((convMode == false) && (hostMode == false)) {
                System.out.println("Trying 1200baud asterisks");
                try {
                    pk232comms.outStream.write("***".getBytes("US-ASCII"));
                } catch (Exception noComms21) {
                    noComms21.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    if (cmdReceived == true) {
                        convMode = true;
                        noCommport = false;
                        jComboBoxBaudrate.setSelectedItem(giniBaudrate);
                    }
                }
            }
            // Forcing 9600 baud and sending 3 CTRL-C's
            if ((convMode == false) && (hostMode == false)) {
                System.out.println("Trying 9600baud CTRL-C");
                pk232comms.serialPort.close();
                giniBaudrate = "9600";
                try {
                    (new pk232comms()).connect(giniCommport, giniStopbits, giniParity, giniDatabits, giniBaudrate);
                } catch (Exception noComms22) {
                    noComms22.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    // This pause is for when we changed comm parms
                }
                try {
                    pk232comms.outStream.write(new byte[]{3, 3, 3});
                } catch (Exception noComms23) {
                    noComms23.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    if (cmdReceived == true) {
                        convMode = true;
                        noCommport = false;
                        jComboBoxBaudrate.setSelectedItem(giniBaudrate);
                    }
                }
            }
            // Forcing 1200 baud and sending 3 CTRL-C's
            if ((convMode == false) && (hostMode == false)) {
                System.out.println("Trying 1200baud CTRL-C");
                pk232comms.serialPort.close();
                giniBaudrate = "1200";
                try {
                    (new pk232comms()).connect(giniCommport, giniStopbits, giniParity, giniDatabits, giniBaudrate);
                } catch (Exception noComms24) {
                    noComms24.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    // This pause is for when we changed comm parms
                }
                try {
                    pk232comms.outStream.write(new byte[]{3, 3, 3});
                } catch (Exception noComms25) {
                    noComms25.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    if (cmdReceived == true) {
                        convMode = true;
                        noCommport = false;
                        jComboBoxBaudrate.setSelectedItem(giniBaudrate);
                    }
                }
            }
            // Forcing 9600 baud and trying KISS mode
            if ((convMode == false) && (hostMode == false)) {
                System.out.println("Trying 9600baud KISS");
                pk232comms.serialPort.close();
                giniBaudrate = "9600";
                try {
                    (new pk232comms()).connect(giniCommport, giniStopbits, giniParity, giniDatabits, giniBaudrate);
                } catch (Exception noComms26) {
                    noComms26.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    // This pause is for when we changed comm parms
                }
                try {
                    pk232comms.outStream.write(new byte[]{(byte) 0xC0, (byte) 0xFF, (byte) 0xC0});
                } catch (Exception noComms27) {
                    noComms27.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    if (cmdReceived == true) {
                        convMode = true;
                        noCommport = false;
                        jComboBoxBaudrate.setSelectedItem(giniBaudrate);
                    }
                }
            }
            // Forcing 1200 baud and trying KISS mode
            if ((convMode == false) && (hostMode == false)) {
                System.out.println("Trying 1200baud KISS");
                pk232comms.serialPort.close();
                giniBaudrate = "1200";
                try {
                    (new pk232comms()).connect(giniCommport, giniStopbits, giniParity, giniDatabits, giniBaudrate);
                } catch (Exception noComms12) {
                    noComms12.printStackTrace();
                }
                try {
                    pk232comms.outStream.write(new byte[]{(byte) 0xC0, (byte) 0xFF, (byte) 0xC0});
                } catch (Exception noComms28) {
                    noComms28.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    if (cmdReceived == true) {
                        convMode = true;
                        noCommport = false;
                        jComboBoxBaudrate.setSelectedItem(giniBaudrate);
                    }
                }
            }
            if ((convMode == true) && (hostMode == false)) {
                // We're connected in convMode, try to set Host mode
                System.out.println("We made it to CONV mode, trying HOST");
                try {
                    // AWLEN 8
                    pk232comms.outStream.write("AWLEN 8".getBytes("US-ASCII"));
                    pk232comms.outStream.write(13);
                } catch (Exception noComms15) {
                    noComms15.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    // Pause just briefly
                }

                // PARITY 0
                try {
                    pk232comms.outStream.write("PARITY 0".getBytes("US-ASCII"));
                    pk232comms.outStream.write(13);
                } catch (Exception noComms16) {
                    noComms16.printStackTrace();
                }

                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    // // Pause just briefly
                }

                // 8BITCONV ON
                try {
                    pk232comms.outStream.write("8BITCONV ON".getBytes("US-ASCII"));
                    pk232comms.outStream.write(13);
                } catch (Exception noComms17) {
                    noComms17.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    // Pause just briefly
                }

                // RESTART
                try {
                    pk232comms.outStream.write("RESTART".getBytes("US-ASCII"));
                    pk232comms.outStream.write(13);
                } catch (Exception noComms18) {
                    noComms18.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    // Pause just briefly
                }
                // HOST ON
                try {
                    pk232comms.outStream.write("HOST ON".getBytes("US-ASCII"));
                    pk232comms.outStream.write(13);
                } catch (Exception noComms19) {
                    noComms19.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    // Pause just briefly
                }
                //XON CANLINE COMMAND
                try {
                    pk232comms.outStream.write(new byte[]{17, 24, 3, 72, 79, 83, 84, 32, 89, 13});
                } catch (Exception noComms20) {
                    noComms20.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    // Pause just briefly
                }
                // Test if in HOST mode CTRL-A CTRL-A 79 71 71 23
                try {
                    pk232comms.outStream.write(new byte[]{1, 1, 79, 71, 71, 23});
                } catch (Exception noComms13) {
                    noComms13.printStackTrace();
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    // Pause for a bit to check if we're in host mode
                }
            }
            if (hostMode == true) {
                //System.out.println("Made it to HOST mode");
                hostmodeDesired = false;
                convMode = false;
                jButtonConnect.setText("Disconnect");
                jLabelMode.setText("Connected");
                jRadioButtonModeMO.setEnabled(true);
                jRadioButtonModePA.setEnabled(true);
                jRadioButtonTx.setEnabled(true);
                jRadioButtonRx.setEnabled(true);
                jRadioButtonRx.setSelected(true);
                //jRadioButtonModePT.setEnabled(true);
                //jRadioButtonModeAS.setEnabled(true);
                //jRadioButtonModeBA.setEnabled(true);
                //jRadioButtonModeAM.setEnabled(true);
                //jToggleButtonHostMode.setEnabled(true);
                jComboBoxBaudrate.setSelectedItem(giniBaudrate);
                jLabelConStatus.setText("HOST");
                // Let's get the opmode
                getOpMode = true;
                try {
                    pk232comms.outStream.write(new byte[]{1, 79, 79, 80, 23});
                } catch (Exception ex2) {
                    ex2.printStackTrace();
                }
                startTime = System.currentTimeMillis();
                while (getOpMode == true) {
                    endTime = System.currentTimeMillis();
                    timeDiff = endTime - startTime;
                    if (timeDiff > 500) {
                        System.out.println("Took too long to get OpMode");
                        break;
                    }
                }
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    // Pause just briefly
                }
                // Can we jump to the Main screen.
                jTabbedPaneMain.setSelectedIndex(0);
            } else {
                // Couldn't get PK232 to communicate
                jLabelConStatus.setText("Disconnected");
                jButtonConnect.setText("Connect");
                pk232comms.serialPort.close();
                jRadioButtonModeMO.setEnabled(false);
                jRadioButtonModePA.setEnabled(false);
                jRadioButtonModePT.setEnabled(false);
                jRadioButtonModeAS.setEnabled(false);
                jRadioButtonModeBA.setEnabled(false);
                jRadioButtonModeAM.setEnabled(false);
                jRadioButtonModeMO.setSelected(false);
                jRadioButtonModePA.setSelected(false);
                jRadioButtonModePT.setSelected(false);
                jRadioButtonModeAS.setSelected(false);
                jRadioButtonModeBA.setSelected(false);
                jRadioButtonModeAM.setSelected(false);
                jLabel7.setText("Found " + giniCommport + ", but could not get command prompt.");
                jLabel8.setText(null);
                jDialogAbout.setLocation(this.getLocationOnScreen().x + 35, this.getLocationOnScreen().y + 35);
                jDialogAbout.setVisible(true);
                hostMode = false;
            }
        } else {
            // Do they want us to disconnect?
            // Couldn't get PK232 to communicate
            jLabelConStatus.setText("Disconnected");
            jButtonConnect.setText("Connect");
            pk232comms.serialPort.close();
            jRadioButtonModeMO.setEnabled(false);
            jRadioButtonModePA.setEnabled(false);
            jRadioButtonModePT.setEnabled(false);
            jRadioButtonModeAS.setEnabled(false);
            jRadioButtonModeBA.setEnabled(false);
            jRadioButtonModeAM.setEnabled(false);
            jRadioButtonModeMO.setSelected(false);
            jRadioButtonModePA.setSelected(false);
            jRadioButtonModePT.setSelected(false);
            jRadioButtonModeAS.setSelected(false);
            jRadioButtonModeBA.setSelected(false);
            jRadioButtonModeAM.setSelected(false);
            hostMode = false;
            convMode = false;
            jToggleButtonMOauto.setSelected(false);
            jRadioButtonRx.setSelected(false);
            jRadioButtonTx.setSelected(false);
            jRadioButtonRx.setEnabled(false);
            jRadioButtonTx.setEnabled(false);
            jToggleButtonMOauto.setEnabled(false);
        }
    }//GEN-LAST:event_jButtonConnectActionPerformed

    public static String chop(String str) {
        if (str == null) {
            return null;
        }
        int strLen = str.length();
        if (strLen < 2) {
            return "";
        }
        int lastIdx = strLen - 1;
        String ret = str.substring(0, lastIdx);
        char last = str.charAt(lastIdx);
        if (last == LF) {
            if (ret.charAt(lastIdx - 1) == CR) {
                return ret.substring(0, lastIdx - 1);
            }
        }
        return ret;
    }

    private void jMenuItemOutputClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemOutputClearActionPerformed
        jTextAreaSerialOut.setText(null);
    }//GEN-LAST:event_jMenuItemOutputClearActionPerformed

    private void jMenuItemOutputCopyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemOutputCopyActionPerformed
        jTextAreaSerialOut.copy();
    }//GEN-LAST:event_jMenuItemOutputCopyActionPerformed

    private void jMenuItemOutputSelAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemOutputSelAllActionPerformed
        jTextAreaSerialOut.selectAll();
    }//GEN-LAST:event_jMenuItemOutputSelAllActionPerformed

    private void jMenuItemInputClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemInputClearActionPerformed
        jTextAreaSerialIn.setText(null);
    }//GEN-LAST:event_jMenuItemInputClearActionPerformed

    private void jMenuItemInputCopyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemInputCopyActionPerformed
        jTextAreaSerialIn.copy();
    }//GEN-LAST:event_jMenuItemInputCopyActionPerformed

    private void jMenuItemInputSelAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemInputSelAllActionPerformed
        jTextAreaSerialIn.selectAll();
    }//GEN-LAST:event_jMenuItemInputSelAllActionPerformed

    private void jButtonAboutOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAboutOkActionPerformed
        jDialogAbout.setVisible(false);
    }//GEN-LAST:event_jButtonAboutOkActionPerformed

    private void jRadioButtonModeMOActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonModeMOActionPerformed
        //if (pkConnected == true) {
        if ((hostMode == true) && (jRadioButtonModeMO.isSelected() == true)) {
            // Host mode CW: SOH $4F $4D $4F ETB
            try {
                // Set MOrse mode
                pk232comms.outStream.write(new byte[]{1, 79, 77, 79, 23});
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    //if (getCWspeed == false) {
                }
                getCWspeed = true;
                // MsPeed (Get CW speed for sending, 5 to 99)
                pk232comms.outStream.write(new byte[]{1, 79, 77, 80, 23});
                for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
                    if (getCWspeed == false) {
                        jLabelCWspeed.setText(Integer.toString(cwSpeed));
                    }
                }
            } catch (Exception ex5) {
                ex5.printStackTrace();
            }
        }
    }//GEN-LAST:event_jRadioButtonModeMOActionPerformed

    private void jRadioButtonModePAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonModePAActionPerformed
        if (jRadioButtonModePA.isFocusOwner()) {
            if (hostMode == true) {
                // Host mode Packet: SOH $4F $50 $41 ETB
                try {
                    // Trying to go into
                    pk232comms.outStream.write(new byte[]{1, 79, 80, 65, 23});
                } catch (Exception ex5) {
                    ex5.printStackTrace();
                }
            } else {
                // Conv mode Packet: $50 $41 $0D
                try {
                    pk232comms.outStream.write(new byte[]{80, 65, 13});
                } catch (Exception ex5) {
                    ex5.printStackTrace();
                }
            }
        }
    }//GEN-LAST:event_jRadioButtonModePAActionPerformed

    private void jRadioButtonModeASActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonModeASActionPerformed
        // Somebody selected the ASCII (RTTY) radio button
    }//GEN-LAST:event_jRadioButtonModeASActionPerformed

    private void jComboBoxDelayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxDelayActionPerformed
        if (jComboBoxDelay.isFocusOwner()) {
            giniDelay = jComboBoxDelay.getSelectedItem().toString().toUpperCase();
        }
    }//GEN-LAST:event_jComboBoxDelayActionPerformed

    private void jTextFieldMyCallActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldMyCallActionPerformed
        if (jTextFieldMyCall.isFocusOwner()) {
            giniMycall = jTextFieldMyCall.getText().toUpperCase();
        }
    }//GEN-LAST:event_jTextFieldMyCallActionPerformed

    private void jTextFieldMyCallFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldMyCallFocusLost
        giniMycall = jTextFieldMyCall.getText().toUpperCase();
    }//GEN-LAST:event_jTextFieldMyCallFocusLost

    private void jComboBoxDelayFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboBoxDelayFocusLost
        giniDelay = jComboBoxDelay.getSelectedItem().toString().toUpperCase();
    }//GEN-LAST:event_jComboBoxDelayFocusLost

    private void jComboBoxPortFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboBoxPortFocusLost
        giniCommport = jComboBoxPort.getSelectedItem().toString().toUpperCase();
    }//GEN-LAST:event_jComboBoxPortFocusLost

    private void jComboBoxDatabitsFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboBoxDatabitsFocusLost
        giniDatabits = jComboBoxDatabits.getSelectedItem().toString().toUpperCase();
    }//GEN-LAST:event_jComboBoxDatabitsFocusLost

    private void jComboBoxParityFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboBoxParityFocusLost
        giniParity = jComboBoxParity.getSelectedItem().toString().toUpperCase();
    }//GEN-LAST:event_jComboBoxParityFocusLost

    private void jComboBoxStopbitsFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboBoxStopbitsFocusLost
        giniStopbits = jComboBoxStopbits.getSelectedItem().toString().toUpperCase();
    }//GEN-LAST:event_jComboBoxStopbitsFocusLost

    private void jComboBoxBaudrateFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboBoxBaudrateFocusLost
        giniBaudrate = jComboBoxBaudrate.getSelectedItem().toString().toUpperCase();
    }//GEN-LAST:event_jComboBoxBaudrateFocusLost

    private void jTextFieldMyNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldMyNameActionPerformed
        if (jTextFieldMyName.isFocusOwner()) {
            giniMyname = jTextFieldMyName.getText();

        }
    }//GEN-LAST:event_jTextFieldMyNameActionPerformed

    private void jToggleButtonServerOnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonServerOnActionPerformed
        //ServerSocket MyService;
        //try {
        //    MyService = new ServerSocket(Integer.parseInt(giniServerPort));
        //}
        //catch (IOException e) {
        //   e.printStackTrace();
        //}
    }//GEN-LAST:event_jToggleButtonServerOnActionPerformed

    private void jTextFieldServerPortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldServerPortActionPerformed
        //if (jTextFieldServerPort.isFocusOwner()) {
        //    if (jTextFieldServerPort.getText() == null) {
        //        giniServerPort = "4442";
        //        jTextFieldServerPort.setText(giniServerPort);
        //     } else {
        //         giniServerPort = jTextFieldServerPort.getText().toUpperCase();
        //     }
        // }
    }//GEN-LAST:event_jTextFieldServerPortActionPerformed

    private void jTextFieldServerPortFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldServerPortFocusLost
    }//GEN-LAST:event_jTextFieldServerPortFocusLost

    private void jButtondispOPmodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtondispOPmodeActionPerformed
        /*
         * if ((pkConnected == true) && (hostMode == true)) { // Debug button,
         * get OPmode and display in console dispOPmode = true; //getOpMode =
         * true; try { pk232comms.outStream.write(new byte[]{1, 79, 79, 80,
         * 23}); //getOpMode = true; for (long stop = System.nanoTime() +
         * TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) { //
         * Pause just briefly } } catch (Exception ex) { ex.printStackTrace(); }
         * }
         *
         */
    }//GEN-LAST:event_jButtondispOPmodeActionPerformed

    private void jRadioButtonModePTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonModePTActionPerformed
        if (jRadioButtonModePT.isFocusOwner()) {
            if (hostMode == true) {
                // Host mode Pactor: SOH $4F $50 $54 ETB
                try {
                    // Trying to go into Pactor
                    pk232comms.outStream.write(new byte[]{1, 79, 80, 116, 23});
                } catch (Exception ex5) {
                    ex5.printStackTrace();
                }
            } /*
             * else { // Conv mode Packet: $50 $41 $0D try {
             * pk232comms.outStream.write(new byte[]{80, 84, 13}); } catch
             * (Exception ex5) { ex5.printStackTrace(); } }
             *
             */
        }
    }//GEN-LAST:event_jRadioButtonModePTActionPerformed

    private void jTextAreaSerialOutKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextAreaSerialOutKeyTyped
        if ((hostMode == true) && (jRadioButtonModeMO.isSelected() == true)) {
            // We're in HOST/CW
            if ((evt.getKeyChar() == '\n') || (evt.getKeyChar() == '\r')) {
                if (cwAuto == true) {
                    //jRadioButtonTx.setSelected(true);
                    try {
                        // Puts into xmit mode
                        pk232comms.outStream.write(new byte[]{1, 79, 88, 77, 23});
                    } catch (Exception sendData) {
                        sendData.printStackTrace();
                    }
                    long startXmit = System.currentTimeMillis();
                    long rightNow;
                    long timeDiff;
                    long startTime;
                    long endTime;
                    while (cwXmit == false) {
                        rightNow = System.currentTimeMillis();
                        timeDiff = rightNow  - startXmit;
                        //System.out.println(timeNow + ":" + testCQxmit + ":" + timeDiff);
                        if (timeDiff > 500) {
                            // We took to long to get into CW mode.
                            System.out.println("Took to long to get into CW xmit." + timeDiff);
                            break;
                        }
                    }
                    //for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(250); stop > System.nanoTime();) {
                        // Pause to see if character was sent.
                    //}
                    //jRadioButtonTx.setSelected(true);
                    int totalLength = serialData2pk.length();
                    int numOfDataPackets = totalLength / 256;
                    int finalPacket = totalLength % 256;
                    String string2send = serialData2pk.toString();
                    //long startTime;
                    //long endTime;
                    //long timeDiff;
                    //long rightNow;
                    for (int i = 0; i < numOfDataPackets; i++) {
                        int startingByte = i * 256;
                        int endingByte = startingByte + 256;
                        byte[] bytes2send = string2send.substring(startingByte, endingByte).getBytes();
                        cwDataSent = true;
                        try {
                            pk232comms.outStream.write(new byte[]{01, 32});
                            pk232comms.outStream.write(bytes2send);
                            pk232comms.outStream.write(23);
                        } catch (Exception ex43) {
                            ex43.printStackTrace();
                        }
                        startTime = System.currentTimeMillis();
                        // WPM is equivalent to 5 chars, so 256 / 5 = 52
                        // time2send is 256/5, then divided by the set CW speed, and them
                        // multiplied by 1000 (milli). Then we're going to add 2 seconds 
                        // just to give it some extra time.
                        float time2send = ((52 / cwSpeed) * 60000) + 2000;
                        while (cwACKwait == false) {
                            if ((System.currentTimeMillis() - startTime) > 500) {
                                // We took to long to send our data.
                                System.out.println("Took to long to receive ack.");
                                break;
                            }
                        }
                        startTime = System.currentTimeMillis();
                        
                        while (dataACK == false) {
                            if ((System.currentTimeMillis() - startTime) > time2send) {
                                System.out.println("Took too long to send.");
                                break;
                            }
                        }
                        System.out.println("We had over 256 characters.");
                    }
                    // lastSend is the amount of time the last piece should take to transmit. (padded by 2 seconds)
                    float lastSend = ((float) ((float) (finalPacket / 5) / cwSpeed) * 60000) + 2000;
                    // The final packet of data packed into bytes for sending.
                    byte[] lastBytes = string2send.substring(totalLength - finalPacket).getBytes();
                    try {
                        pk232comms.outStream.write(new byte[]{01, 32});
                        pk232comms.outStream.write(lastBytes);
                        pk232comms.outStream.write(23);
                    } catch (Exception dataSend2) {
                        dataSend2.printStackTrace();
                    }
                    cwACKwait = false;
                    startTime = System.currentTimeMillis();
                    while (cwACKwait == false) {
                        rightNow = System.currentTimeMillis();
                        timeDiff = rightNow - startTime;
                        if (timeDiff > 500) {
                            // Didn't get an ACK within 500ms
                            System.out.println("Didn't get a cw ack");
                            break;
                        }
                    }
                    dataACK = false;
                    startTime = System.currentTimeMillis();
                    //while (dataACK == false) {
                    //    rightNow = System.currentTimeMillis();
                    //    timeDiff = rightNow - startTime;
                    //    if (timeDiff > lastSend) {
                    //        // Didn't get an ack to our sent data
                    //        System.out.print(".");
                    //        //break;
                    //    }
                    //}
                    //System.out.println(System.currentTimeMillis() - lastTime);

                    
                    // Do you think for cw send, we'll need to constantly query
                    // and check to see when HPOLL returns 
                    dataFinished = false;
                    while (dataFinished == false) {
                        try {
                            pk232comms.outStream.write(new byte[] {1, 79, 71, 71, 23});
                        } catch (Exception poll232) {
                            poll232.printStackTrace();
                        }
                    }
                    // Put us back into receive mode
                    try {
                        pk232comms.outStream.write(new byte[]{1, 79, 82, 67, 23});
                    } catch (Exception dataSend3) {
                        dataSend3.printStackTrace();
                    }
                    for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(250); stop > System.nanoTime();) {
                        // Pause to see if character was sent.
                    }
                    //jRadioButtonRx.setSelected(true);
                    serialData2pk.setLength(0);
                } else {
                    // Not in auto, just start sending.
                    try {
                        pk232comms.outStream.write(new byte[]{1, 79, 88, 77, 23});
                        pk232comms.outStream.write(new byte[]{1, 32, (byte) evt.getKeyChar(), 23});
                        pk232comms.outStream.write(new byte[]{1, 79, 82, 67, 23});
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            } else if (evt.getKeyChar() == 8) {
                serialData2pk.deleteCharAt(serialData2pk.length() - 1);
            } else {
                serialData2pk.append(evt.getKeyChar());
            }
            /*
             * } else if (pkConnected == true) { // We're not in HOST mode, but
             * we are connected if ((evt.getKeyChar() == '\n') ||
             * (evt.getKeyChar() == '\r')) { serialData2pk.append('\r'); try {
             * pk232comms.outStream.write(serialData2pk.toString().getBytes("US-ASCII"));
             * } catch (Exception ex) { ex.printStackTrace(); }
             * serialData2pk.setLength(0); } else if (evt.getKeyChar() == 8) {
             * serialData2pk.deleteCharAt(serialData2pk.length() - 1); } else {
             * serialData2pk.append(evt.getKeyChar()); }
             *
             */
        } else {
            // We're not connected, what are you trying to do here?
            jLabel7.setText("You're not connected to the PK232.");
            jLabel8.setText(null);
            jDialogAbout.setLocation(this.getLocationOnScreen().x + 35, this.getLocationOnScreen().y + 35);
            jDialogAbout.setVisible(true);
        }

    }//GEN-LAST:event_jTextAreaSerialOutKeyTyped

    private void jToggleButtonMOautoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonMOautoActionPerformed
        if (jToggleButtonMOauto.isSelected() == true) {
            cwAuto = true;
            System.out.println("CWA turned on.");
            jRadioButtonTx.setEnabled(false);
            jRadioButtonRx.setEnabled(false);
        } else {
            cwAuto = false;
            System.out.println("CWA turned off.");
            jRadioButtonTx.setEnabled(true);
            jRadioButtonRx.setEnabled(true);
        }
    }//GEN-LAST:event_jToggleButtonMOautoActionPerformed

    private void jButtonOuttaHostActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOuttaHostActionPerformed
        // Try to get us out of HOST mode
        try {
            pk232comms.outStream.write(new byte[]{1});
        } catch (Exception outtaHost) {
            outtaHost.printStackTrace();
        }
        for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
            //if (getCWspeed == false) {
        }
        try {
            pk232comms.outStream.write(new byte[]{1, 79, 72, 79, 78, 23});
        } catch (Exception outtaHost2) {
            outtaHost2.printStackTrace();
        }
        for (long stop = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(1000); stop > System.nanoTime();) {
            //if (getCWspeed == false) {
        }
    }//GEN-LAST:event_jButtonOuttaHostActionPerformed

    private void jRadioButtonTxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonTxActionPerformed
        if (jRadioButtonTx.isSelected()) {
            try {
                // Puts into xmit mode
                pk232comms.outStream.write(new byte[]{1, 79, 88, 77, 23});
            } catch (Exception sendData) {
                sendData.printStackTrace();
            }
        }
    }//GEN-LAST:event_jRadioButtonTxActionPerformed

    private void jRadioButtonRxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonRxActionPerformed
        if (jRadioButtonRx.isSelected()) {
            // Put us back into receive mode
            try {
                pk232comms.outStream.write(new byte[]{1, 79, 82, 67, 23});
            } catch (Exception dataSend3) {
                dataSend3.printStackTrace();
            }
        }
    }//GEN-LAST:event_jRadioButtonRxActionPerformed

    private void jButtonSendCodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSendCodeActionPerformed
        // Let's send a code to the PK232
        int val2send = Integer.parseInt(jTextFieldCode2send.getText());
        System.out.println(val2send);
        try {
            pk232comms.outStream.write((byte) val2send);
        } catch (Exception dataSend3) {
            dataSend3.printStackTrace();
        }
    }//GEN-LAST:event_jButtonSendCodeActionPerformed
    public static void main(String args[]) {

        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;








                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(pk232guru.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(pk232guru.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(pk232guru.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(pk232guru.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new pk232guru().setVisible(true);
            }
        });
    }

    static void getIniContents(String filename) throws IOException {
        Wini iniPk232 = new Wini(new File(filename));
        giniCommport = iniPk232.get("pk232", "commport", String.class);
        giniBaudrate = iniPk232.get("pk232", "baudrate", String.class);
        giniDatabits = iniPk232.get("pk232", "databits", String.class);
        giniParity = iniPk232.get("pk232", "parity", String.class);
        giniStopbits = iniPk232.get("pk232", "stopbits", String.class);
        giniDelay = iniPk232.get("pk232", "delay", String.class);
        giniMycall = iniPk232.get("personal", "callsign", String.class);
        giniServerPort = iniPk232.get("server", "port", String.class);
        giniMyname = iniPk232.get("personal", "name", String.class);
        if (giniCommport
                == null) {
            giniCommport = "COM3";
        } else {
            giniCommport = giniCommport.toUpperCase();
        }
        if (giniBaudrate
                == null) {
            giniBaudrate = "9600";
        }
        if (giniDatabits
                == null) {
            giniDatabits = "8";
        }
        if (giniStopbits
                == null) {
            giniStopbits = "1";
        }
        if (giniParity
                == null) {
            giniParity = "NONE";
        } else {
            giniParity = giniParity.toUpperCase();
        }
        if (giniDelay
                == null) {
            giniDelay = "2";
        }
        if ((giniMycall
                == null) || (giniMycall.equals(
                ""))) {
            giniMycall = "FAKE";
        } else {
            giniMycall = giniMycall.toUpperCase();
        }
        if (giniServerPort
                == null) {
            giniServerPort = "4442";
        }
        if (giniMyname
                == null) {
            giniMyname = "Bob";
        }

        jComboBoxPort.removeAllItems();

        jComboBoxPort.addItem(
                "Select One");
        jComboBoxPort.addItem(
                "Refresh");
        jComboBoxPort.addItem(giniCommport);

        listPorts();

        jComboBoxPort.setSelectedItem(giniCommport.toUpperCase());
        jComboBoxBaudrate.setSelectedItem(giniBaudrate);

        jComboBoxDatabits.setSelectedItem(giniDatabits);

        jComboBoxStopbits.setSelectedItem(giniStopbits);

        jComboBoxParity.setSelectedItem(giniParity.toUpperCase());
        jComboBoxDelay.setSelectedItem(giniDelay);

        jTextFieldMyCall.setText(giniMycall.toUpperCase());
        jTextFieldServerPort.setText(giniServerPort.toUpperCase());

        jTextFieldMyName.setText(giniMyname);
    }

    static void setIniContents(String filename) throws IOException {
        Wini iniPk232 = new Wini(new File(filename));
        iniPk232.put("pk232", "commport", giniCommport.toUpperCase());
        iniPk232.put("pk232", "baudrate", giniBaudrate.toUpperCase());
        iniPk232.put("pk232", "databits", giniDatabits.toUpperCase());
        iniPk232.put("pk232", "parity", giniParity.toUpperCase());
        iniPk232.put("pk232", "stopbits", giniStopbits.toUpperCase());
        iniPk232.put("pk232", "delay", giniDelay.toUpperCase());
        iniPk232.put("personal", "callsign", giniMycall.toUpperCase());
        iniPk232.put("server", "port", giniServerPort.toUpperCase());
        iniPk232.store();
    }

    static void listPorts() {
        java.util.Enumeration<CommPortIdentifier> portEnum = CommPortIdentifier.getPortIdentifiers();
        while (portEnum.hasMoreElements()) {
            CommPortIdentifier portIdentifier = portEnum.nextElement();
            if (getPortTypeName(portIdentifier.getPortType()).equals("Serial")) {
                if (portIdentifier.getName().equals(giniCommport)) {
                    // Entry exists, don't add it again.
                } else {
                    jComboBoxPort.addItem(portIdentifier.getName());
                }
            }
        }
    }

    static String getPortTypeName(int portType) {
        switch (portType) {
            case CommPortIdentifier.PORT_I2C:
                return "I2C";
            case CommPortIdentifier.PORT_PARALLEL:
                return "Parallel";
            case CommPortIdentifier.PORT_RAW:
                return "Raw";
            case CommPortIdentifier.PORT_RS485:
                return "RS485";
            case CommPortIdentifier.PORT_SERIAL:
                return "Serial";
            default:
                return "unknown type";
        }
    }
    // <editor-fold defaultstate="collapsed" desc="Component Defines">
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroupMode;
    private javax.swing.ButtonGroup buttonGroupRxTx;
    private javax.swing.JButton jButtonAboutOk;
    private javax.swing.JButton jButtonConnect;
    private javax.swing.JButton jButtonOuttaHost;
    private javax.swing.JButton jButtonReadINI;
    public static javax.swing.JButton jButtonSendCode;
    private javax.swing.JButton jButtonWriteINI;
    public static javax.swing.JComboBox jComboBoxBaudrate;
    public static javax.swing.JComboBox jComboBoxDatabits;
    public static javax.swing.JComboBox jComboBoxDelay;
    public static javax.swing.JComboBox jComboBoxParity;
    public static javax.swing.JComboBox jComboBoxPort;
    public static javax.swing.JComboBox jComboBoxStopbits;
    private javax.swing.JDialog jDialogAbout;
    private javax.swing.JFileChooser jFileChooseINI;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    public static javax.swing.JLabel jLabelCWspeed;
    private javax.swing.JLabel jLabelConStatus;
    private javax.swing.JLabel jLabelMode;
    private javax.swing.JLabel jLabelMorseSpeed;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuExit;
    private javax.swing.JMenu jMenuFile;
    private javax.swing.JMenu jMenuHelp;
    private javax.swing.JMenuItem jMenuHelpAbout;
    private javax.swing.JMenuItem jMenuItemInputClear;
    private javax.swing.JMenuItem jMenuItemInputCopy;
    private javax.swing.JMenuItem jMenuItemInputSelAll;
    private javax.swing.JMenuItem jMenuItemOutputClear;
    private javax.swing.JMenuItem jMenuItemOutputCopy;
    private javax.swing.JMenuItem jMenuItemOutputSelAll;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanelMain;
    private javax.swing.JPanel jPanelPersonal;
    private javax.swing.JPanel jPanelSettings;
    private javax.swing.JPopupMenu jPopupMenuInput;
    private javax.swing.JPopupMenu jPopupMenuOutput;
    public static javax.swing.JRadioButton jRadioButtonModeAM;
    public static javax.swing.JRadioButton jRadioButtonModeAS;
    public static javax.swing.JRadioButton jRadioButtonModeBA;
    public static javax.swing.JRadioButton jRadioButtonModeMO;
    public static javax.swing.JRadioButton jRadioButtonModePA;
    public static javax.swing.JRadioButton jRadioButtonModePT;
    public static javax.swing.JRadioButton jRadioButtonRx;
    public static javax.swing.JRadioButton jRadioButtonTx;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    public static javax.swing.JSlider jSliderCWspeed;
    public static javax.swing.JTabbedPane jTabbedPaneMain;
    public static javax.swing.JTextArea jTextAreaSerialIn;
    public static javax.swing.JTextArea jTextAreaSerialOut;
    public static javax.swing.JTextField jTextFieldCode2send;
    public static javax.swing.JTextField jTextFieldMyCall;
    private javax.swing.JTextField jTextFieldMyGrid;
    public static javax.swing.JTextField jTextFieldMyName;
    public static javax.swing.JTextField jTextFieldServerPort;
    public static javax.swing.JToggleButton jToggleButtonMOauto;
    private javax.swing.JToggleButton jToggleButtonServerOn;
    // End of variables declaration//GEN-END:variables
}// </editor-fold>

